Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21367: [Spike] Nightly job to filter and sync contacts #241

Merged
merged 38 commits into from
Oct 29, 2024

Conversation

VSydor
Copy link
Contributor

@VSydor VSydor commented Aug 28, 2024

No description provided.

@VSydor VSydor requested a review from brmeyer August 28, 2024 21:54
@VSydor VSydor self-assigned this Aug 28, 2024
@VSydor VSydor force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch from 65c65d1 to 36ff8f1 Compare September 2, 2024 21:39
@VSydor VSydor changed the title WIP: 21367: Initial commit 21367: [Spike] Nightly job to filter and sync contacts Sep 2, 2024
@VSydor VSydor force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch from 30a8db5 to 7bcf057 Compare September 10, 2024 20:24
@VSydor VSydor requested a review from brmeyer September 11, 2024 20:51
@VSydor VSydor force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch from ea1d1f8 to 75ef24c Compare September 11, 2024 22:14
@VSydor VSydor requested a review from brmeyer September 25, 2024 22:16
@@ -25,6 +25,9 @@ public class AccountingTransaction {
public String paymentGatewayName;
public String paymentGatewayTransactionId;
public Boolean recurring;
//TODO: find a way of passing crm object custom fields to accounting layer
// (configurable list of custom fields' names? extract into a map to use instead of entire crmDonation object?)
public CrmDonation crmDonation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VSydor Can you clarify why this is needed? Are there additional fields that we need to save in Xero itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nm, I see it. updateOrCreateTransactions only has access to the accountingTransactions, right? Do we need to refactor a bit? Have this method receive the List<CrmContact> directly, and then we move the translation into List<AccountingTransaction> here instead of upstream in XeroDataSyncService?

Copy link
Contributor Author

@VSydor VSydor Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to add crmdonation here bcz need to check custom fields in the XeroAccountingPlatformService (WPG__c, Tax_Deductible_Gift__c, Other_Income__c).

Can add List directly to updateOrCreateTransactions method and then do translation inside XeroAccountingPlatformService for sure.

env.logJobError("Failed to upsert invoices! {}", getExceptionDetails(e));
throw e;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VSydor Don't we need a dr-hub PR to override this? dr-hub overrode the original createTransaction to turn TICKET transactions into a Bank Transaction (skipping the Invoice).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Will add the needed changes in dr-hub.

return queryResults;
}

protected QueryResult queryDonorContacts(String updatedSinceClause, String... extraFields) throws ConnectionException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VSydor One thing I realized we're missing in this: querying for business accounts. Check out AccountingService.getDonationContact. Similar to what we're doing for the MC sync, if the donation only had an Account associated with it and not a Contact, we might still need to create a faux CrmContact. Otherwise, that organization will not have created a Xero Contact by the time we sync its donations.

Ex: https://destinyrescue-fnsf.lightning.force.com/lightning/r/Opportunity/006J3000003wRMNIA2/view (business gift, no contact on the gift, no primary contact defined on the account).

So we might have to introduce that faux contact concept for this as well (further upstream, though)? Query for all non-household Accounts that are donors and updated since the date, create faux CrmContacts for them, and sync those to Xero as well?

Actually, I partially take that back. Since they want the "ContactPerson" included, we have to get a contact in addition to the business? Query for non-household accounts, get their primary contacts, and then return those as CrmContacts with the CrmAccount included inside it?

Not all Accounts have primary contacts defined on them in SFDC. Many do, but it's optional. In the doc, I have a convo going in the doc with Maria on what to do in this case. Most of them WILL at least have an affiliation defined that we could use to get a Contact...

if ("true".equalsIgnoreCase(getCustomDonationField(accountingTransaction, WPG_FIELD_NAME))) {
lineItem.setAccountCode("120");
lineItem.setItemCode("RecurringWPG");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just CC'd you on a question to Maria on https://docs.google.com/document/d/1wEjPtMvVwZr-k3lFa5D6M9NgP6IGZn_v/edit. This code would be creating a single invoice coded to 120 if a recurring gift had WPG=true in SFDC. Which MIGHT be correct. But as I reread what they had in their mappings, wondering if what they want is BOTH an invoice coded to 122 AND a "receive money" coded to 120.

IIRC, they want the latter, so we'd need to break this up to create both an invoice and a receive money with their independent line items. That's currently done by dr-hub's overridden createTransaction, but we could get rid of that and just do it here...

@VSydor VSydor requested a review from brmeyer September 27, 2024 22:19
@VSydor VSydor force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch from af8b293 to 612c5b5 Compare September 27, 2024 22:25
@VSydor VSydor force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch 2 times, most recently from 0b06456 to af37dcb Compare October 9, 2024 21:28
@brmeyer brmeyer force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch 2 times, most recently from b037855 to d1cc80f Compare October 16, 2024 00:01
VSydor and others added 25 commits October 23, 2024 13:46
…d AccountingTransaction and replaced with direct usage of CrmDonation/CrmContact/CrmAccount, deleting dead code, attempting to post invoices using contact accountNumber instead of UUID
…n't work), paging the getInvoices/getTransactions calls, more simplifications/refactors
@brmeyer brmeyer force-pushed the feature/21367-nightly-job-to-filter-and-sync-contacts branch from b596018 to 7ea980f Compare October 23, 2024 17:46
@brmeyer brmeyer merged commit ef68f2f into master Oct 29, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants